var req;
var req2;

function navigate(month,year) {
		id  = document.getElementById("ruteid").value;
	//	start=document.getElementById("rutestart").value;       
		var url = "ajax/calendar/calendar.php?month="+month+"&year="+year+"&id="+id;//+"&start="+start;
		if(window.XMLHttpRequest) {
                req = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req = new ActiveXObject("Microsoft.XMLHTTP");
        }
	//	alert(id+":"+start);
        req.open("GET", url, true);
        req.onreadystatechange = callback;
        req.send(null);
}

function selecttime(year,month,day,idd,startd){
	//	alert("test");
		var url2 = "ajax/calendar/calendar.php?year="+year+"&month="+month+"&day="+day+"&id="+idd;//+"&st='"+startd+"'";
//		alert(url2);
		if(window.XMLHttpRequest) {
                req2 = new XMLHttpRequest();
        } else if(window.ActiveXObject) {
                req2 = new ActiveXObject("Microsoft.XMLHTTP");
        } else {
			alert("error");
		}
		//alert("erro");
        req2.open("GET", url2, true);
        req2.onreadystatechange = callback2;
        req2.send(null);
}

function callback() {        
        obj = document.getElementById("calendar");
        setFade(0);
        
		if(req.readyState == 4) {
                if(req.status == 200) {
                        response = req.responseText;
                        obj.innerHTML = response;
                        fade(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req.statusText);
                }
        }
}


function callback2() {        
	   obj = document.getElementById("time");
        setFade(0);
        
		if(req2.readyState == 4) {
                if(req2.status == 200) {
                        response = req2.responseText;
                        obj.innerHTML = response;
                        fade(0);
                } else {
                        alert("There was a problem retrieving the data:\n" + req2.statusText);
                }
        }
}

function fade(amt) {
	if(amt <= 100) {
		setFade(amt);
		amt += 5;
		setTimeout("fade("+amt+")", 5);
    }
}

function setFade(amt) {
	obj = document.getElementById("calendar");
	
	amt = (amt == 100)?99.999:amt;
  
	// IE
	obj.style.filter = "alpha(opacity:"+amt+")";
  
	// Safari<1.2, Konqueror
	obj.style.KHTMLOpacity = amt/100;
  
	// Mozilla and Firefox
	obj.style.MozOpacity = amt/100;
  
	// Safari 1.2, newer Firefox and Mozilla, CSS3
	obj.style.opacity = amt/100;
}
/*
function settime(){
alert("Settime-metoden brukes da ikke?");
var no=document.getElementById("klokke");
var option=no.options[no.selectedIndex].text;
var txt=document.getElementById("li");//.value;
text=txt.value + "<a href='?page=predef&id=+txt.index&time="+option+"'>Klikk meg</a>";
document.getElementById("li").value=txt;
txt.innerHTML = text;
}*/